/*
 * Copyright 2020-2021 redragon.dongbin
 *
 * This file is part of redragon-erp/赤龙ERP.

 * redragon-erp/赤龙ERP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.

 * redragon-erp/赤龙ERP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with redragon-erp/赤龙ERP.  If not, see <https://www.gnu.org/licenses/>.
 */
package com.erp.cux.workflow.service.spring;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.redragon.framework.annotation.Cache;
import org.redragon.framework.annotation.Cache.CacheType;
import org.redragon.framework.annotation.Log;
import org.redragon.framework.hibernate.model.Pages;
//import org.redragon.framework.util.FormulaUtil;

import com.erp.cux.workflow.dao.CuxWorkflowConfLineDao;
import com.erp.cux.workflow.dao.model.CuxWorkflowConfLine;
import com.erp.cux.workflow.dao.model.CuxWorkflowConfLineCO;
import com.erp.cux.workflow.service.CuxWorkflowConfLineService;

@Service
@Transactional(rollbackFor=Exception.class)
public class CuxWorkflowConfLineServiceImpl implements CuxWorkflowConfLineService {

    //注入Dao
    @Autowired
    private CuxWorkflowConfLineDao cuxWorkflowConfLineDao;
    
    @Override
    public void insertDataObject(CuxWorkflowConfLine obj) {
        this.cuxWorkflowConfLineDao.insertDataObject(obj);
    }

    @Override
    public void updateDataObject(CuxWorkflowConfLine obj) {
        this.cuxWorkflowConfLineDao.updateDataObject(obj);
    }
    
    @Override
    public void insertOrUpdateDataObject(CuxWorkflowConfLine obj) {
        this.cuxWorkflowConfLineDao.insertOrUpdateDataObject(obj);
    }

    @Override
    public void deleteDataObject(CuxWorkflowConfLine obj) {
        this.cuxWorkflowConfLineDao.deleteDataObject(obj);
    }

    @Override
    public List<CuxWorkflowConfLine> getDataObjects() {
        return this.cuxWorkflowConfLineDao.getDataObjects();
    }

    @Override
    public CuxWorkflowConfLine getDataObject(int id) {
        return this.cuxWorkflowConfLineDao.getDataObject(id);
    }

    @Override
    public CuxWorkflowConfLine getDataObject(String code) {
        return this.cuxWorkflowConfLineDao.getDataObject(code);
    }

    @Override
    public List<CuxWorkflowConfLine> getDataObjects(CuxWorkflowConfLineCO paramObj) {
        return this.cuxWorkflowConfLineDao.getDataObjects(paramObj);
    }

    @Override
    public List<CuxWorkflowConfLine> getDataObjects(Pages pages) {
        return this.cuxWorkflowConfLineDao.getDataObjects(pages);
    }
    
    @Override
    public List<CuxWorkflowConfLine> getDataObjects(Pages pages, CuxWorkflowConfLineCO paramObj) {
        return this.cuxWorkflowConfLineDao.getDataObjects(pages, paramObj);
    }
    
    @Override
    public List<Map<String, Object>> getDataObjectsArray(Pages pages, CuxWorkflowConfLineCO paramObj) {
        return this.cuxWorkflowConfLineDao.getDataObjectsArray(pages, paramObj);
    }
    
    @Override
    public List<CuxWorkflowConfLine> getDataObjectsForDataAuth(String dataAuthSQL, Pages pages, CuxWorkflowConfLineCO paramObj) {
        return this.cuxWorkflowConfLineDao.getDataObjectsForDataAuth(dataAuthSQL, pages, paramObj);
    }
    
    @Override
    public int getCuxWorkflowConfLineCountByHeadCode(String headCode) {
        return this.cuxWorkflowConfLineDao.getCuxWorkflowConfLineCountByHeadCode(headCode);
    }
    
    @Override
    public List<CuxWorkflowConfLine> getCuxWorkflowConfLineListByHeadCode(Pages pages, CuxWorkflowConfLineCO paramObj) {
        return this.cuxWorkflowConfLineDao.getCuxWorkflowConfLineListByHeadCode(pages, paramObj);
    }
    
    @Override
    public List<CuxWorkflowConfLine> getBranchTaskListByTaskCode(String headCode, String taskCode) {
        return this.cuxWorkflowConfLineDao.getBranchTaskListByTaskCode(headCode, taskCode);
    }
    
    @Override
    public CuxWorkflowConfLine getFirstTaskByWorkflow(String headCode) {
        return this.cuxWorkflowConfLineDao.getFirstTaskByWorkflow(headCode);
    }
    
    @Override
    public CuxWorkflowConfLine getNextTaskByTaskCode(String headCode, String taskCode, Map<String, Object> params) {
        //获取当前节点的所有分支
       /* List<CuxWorkflowConfLine> cuxWorkflowConfLineList = this.cuxWorkflowConfLineDao.getBranchTaskListByTaskCode(headCode, taskCode);
        //循环判定分支条件是否成立
        for(CuxWorkflowConfLine cuxWorkflowConfLine: cuxWorkflowConfLineList) {
            //获取条件并执行返回boolean结果
            String branchCondition = cuxWorkflowConfLine.getBranchCondition();
            Object result = FormulaUtil.convertToCode(branchCondition, params);
            if(Boolean.parseBoolean(String.valueOf(result))) {
                return cuxWorkflowConfLine;
            }
        }*/
        return null;
    }
    
}